package com.bicycle.rentalsystem.dao.impl.user;

import com.bicycle.rentalsystem.dao.admin.LeaseDao;
import com.bicycle.rentalsystem.handler.SingleResultHandler;
import com.bicycle.rentalsystem.jdbc.JdbcUtil;
import com.bicycle.rentalsystem.pojo.user.LeaseInfo;

public class LeaseDaoImpl implements LeaseDao {
    @Override
    public LeaseInfo getLeaseInfo(String username) {
        String sql = "SELECT bid,number,type,bname,holder,status FROM bicycle WHERE holder = ?";
        return JdbcUtil.query(sql,new SingleResultHandler<>(LeaseInfo.class),username);
    }

    @Override
    public int returnBike(String username) {
        String sql = "UPDATE `bicycle` SET `holder`='', `status`='未租赁' WHERE (`holder` = ?)";
        return JdbcUtil.update(sql,username);
    }
}
